package com.ruoyi.web.controller.activiti;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.activiti.domain.ActReDeployment;
import com.ruoyi.activiti.service.IActReDeploymentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * activitiController
 * 
 * @author ldx
 * @date 2020-12-05
 */
@Controller
@RequestMapping("/activiti/activiti")
public class ActReDeploymentController extends BaseController
{
    private String prefix = "activiti/activiti";

    @Autowired
    private IActReDeploymentService actReDeploymentService;

    @RequiresPermissions("activiti:activiti:view")
    @GetMapping()
    public String activiti()
    {
        return prefix + "/activiti";
    }

    /**
     * 查询activiti列表
     */
    @RequiresPermissions("activiti:activiti:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActReDeployment actReDeployment)
    {
        startPage();
        List<ActReDeployment> list = actReDeploymentService.selectActReDeploymentList(actReDeployment);
        return getDataTable(list);
    }

    /**
     * 导出activiti列表
     */
    @RequiresPermissions("activiti:activiti:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActReDeployment actReDeployment)
    {
        List<ActReDeployment> list = actReDeploymentService.selectActReDeploymentList(actReDeployment);
        ExcelUtil<ActReDeployment> util = new ExcelUtil<ActReDeployment>(ActReDeployment.class);
        return util.exportExcel(list, "activiti");
    }

    /**
     * 新增activiti
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存activiti
     */
    @RequiresPermissions("activiti:activiti:add")
    @Log(title = "activiti", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActReDeployment actReDeployment)
    {
        return toAjax(actReDeploymentService.insertActReDeployment(actReDeployment));
    }

    /**
     * 修改activiti
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ActReDeployment actReDeployment = actReDeploymentService.selectActReDeploymentById(id);
        mmap.put("actReDeployment", actReDeployment);
        return prefix + "/edit";
    }

    /**
     * 修改保存activiti
     */
    @RequiresPermissions("activiti:activiti:edit")
    @Log(title = "activiti", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActReDeployment actReDeployment)
    {
        return toAjax(actReDeploymentService.updateActReDeployment(actReDeployment));
    }

    /**
     * 删除activiti
     */
    @RequiresPermissions("activiti:activiti:remove")
    @Log(title = "activiti", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actReDeploymentService.deleteActReDeploymentByIds(ids));
    }
}
